import com.huaweicloud.sdk.iot.device.client.requests.CommandRsp;
import com.huaweicloud.sdk.iot.device.service.AbstractService;
import com.huaweicloud.sdk.iot.device.service.DeviceCommand;
import com.huaweicloud.sdk.iot.device.service.Property;

import java.util.Map;
import java.util.Random;

public class Fs extends AbstractService {

    public int getFs() {
        fs = new Random().nextInt(100);
        return fs;
    }

    public void setFs(int fs) {
        this.fs = fs;
    }

    //按照设备模型定义属性，注意属性的name和类型需要和模型一致，writeable表示属性知否可写，name指定属性名
    @Property(name = "fs", writeable = true)                  //可读true
            int fs = 1;


    //定义命令，注意接口入参和返回值类型是固定的不能修改，否则会出现运行时错误
    @DeviceCommand(name = "chakan")
    public CommandRsp alarm(Map<String, Object> paras) {
        int chakan = (int) paras.get("chakan");
        System.out.println("chakan  chakan = " + chakan);
        //将log换成System.out.println
        CommandRsp commandRsp=new CommandRsp(0);
        commandRsp.setResponseName("COMMAND_RESPONSE");
        //定制
        return commandRsp;
    }

}

